#Yum 依赖库
    yum -y install gcc gcc-c++ make libtool zlib zlib-devel openssl openssl-devel pcre pcre-devel gd-devel  unzip   libmaxminddb-devel GeoIP-devel.x86_64
#下载ngx_http_geoip2_module模块
    wget https://gitee.com/zjkguo/ywjb/raw/master/soft/ngx_http_geoip2_module-3.4.zip
    unzip ngx_http_geoip2_module-3.4.zip
#下载Geoip地图文件，最新的版本单独下载官网地址：http://www.maxmind.com
    mkdir -p /usr/local/GeoLite2
    wget https://gitee.com/zjkguo/ywjb/raw/master/soft/GeoLite2-City_20240112.tar.gz -O /usr/local/GeoLite2/GeoLite2-City_20240112.tar.gz  && tar -xvf /usr/local/GeoLite2/GeoLite2-City_20240112.tar.gz
    wget https://gitee.com/zjkguo/ywjb/raw/master/soft/GeoLite2-Country_20240112.tar.gz -O /usr/local/GeoLite2/GeoLite2-Country_20240112.tar.gz && tar -xvf /usr/local/GeoLite2/GeoLite2-Country_20240112.tar.gz
#Tengine 部署
    wget https://tengine.taobao.org/download/tengine-3.1.0.tar.gz
    tar -zxvf tengine-3.1.0.tar.gz
    cd tengine-3.1.0
    ./configure  --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/sbin/nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_image_filter_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module   --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module   --with-http_stub_status_module    --with-http_geoip_module    --with-http_v2_module --with-debug  --add-module=./modules/ngx_http_upstream_check_module/ --add-module=./modules/ngx_http_concat_module --add-module=./modules/ngx_http_sysguard_module    --add-module=../ngx_http_geoip2_module-3.4
    make && make install
#Tengine 配置    
    wget https://gitee.com/zjkguo/ywjb/raw/master/soft/nginx -O /etc/init.d/nginx
    #wget https://gitee.com/zjkguo/ywjb/raw/master/soft/nginx.conf -O /etc/nginx/nginx.conf
    wget https://gitee.com/zjkguo/ywjb/raw/master/soft/nginx-geoip.conf -O /etc/nginx/nginx.conf
    mkdir /etc/nginx/vhosts
    mkdir -p /data/logs/nginx/access
    mkdir -p /data/logs/nginx/error
#wget https://gitee.com/zjkguo/ywjb/raw/master/soft/xxx.com.conf -O /etc/nginx/vhosts/xxx.com.conf
    mv /usr/local/nginx/logs /usr/local/nginx/logs-back
    ln -s /data/logs/nginx  /usr/local/nginx/logs

#启动脚本
cat >> /usr/lib/systemd/system/nginx.service << EOF 
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
 
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/bin/rm -f /run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
KillMode=process
KillSignal=SIGQUIT
TimeoutStopSec=5
PrivateTmp=true
 
[Install]
WantedBy=multi-user.target

EOF

#重新加载 systemd
systemctl daemon-reload

#设置nginx服务开机自启动
systemctl enable nginx.service

#启动nginx服务
systemctl start nginx.service

#Json 
wget https://gitee.com/zjkguo/ywjb/raw/master/soft/jq-linux-amd64 -O /usr/local/bin/jq
chmod +x  /usr/local/bin/jq